<template>
  <span>
    <el-option
      v-for="option in state.options"
      :key="option.code"
      :label="option.label"
      :value="option.value"
    ></el-option>
  </span>
</template>

<script setup lang="ts" name="dicItemsSelectOption">
import { useSysApi } from "/@/api/sys/index";
import { onMounted, reactive,defineProps } from 'vue';
const props = defineProps({ dicCode: String, microServiceName: String, language: String, dataType: String, withNullValue: Boolean })


const refresh = () => {
  useSysApi().selectDicItemsByDicCodeToNameAndValue(props.dicCode, props.microServiceName, props.language, props.dataType).then(data => {
    if (props.withNullValue) {
        if (props.language == "en_US") {
          data.unshift({ label: "All" });
        } else {
          data.unshift({ label: "全部" });
        }
      }
      state.options = data;
  });
};

let state = reactive({ options: [] as any });

onMounted(() => {
  refresh()
});
</script>